tools: ocaml: remove non-posix-ism from sed script.
authorIan Campbell <ian.campbell@citrix.com>
Tue, 24 May 2011 16:52:02 +0000 (17:52 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 24 May 2011 16:52:02 +0000 (17:52 +0100)
Christoph Egger reported than on NetBSD the build fails with

Parsing tools/ocaml/libs/xl/../../../../tools/libxl/libxl.idl
sed: 1: "1i(*\
  * AUTO-GENERATED ...": command i expects \ followed by test
gmake[7]: Leaving directory `tools/ocaml/libs/xl'

The following was tested by Christoph on NetBSD and also with GNU-sed
with and without the --posix flag.

In addition when sed fails will still create the output file, which confuses
subsequent make invocations. Generate to a temporary file and move into place
only on success.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/ocaml/libs/xl/Makefile

index decdf62a5a033528424c5a715cee373c38f20fe0..342dc3511ab7eaab710ceb3fabca38afd2c92138 100644 (file)
@@ -17,29 +17,33 @@ xl_C_OBJS = xl_stubs
 
 OCAML_LIBRARY = xl
 
-GENERATED_FILES += xl.ml xl.mli
+GENERATED_FILES += xl.ml xl.ml.tmp xl.mli xl.mli.tmp
 GENERATED_FILES += _libxl_types.ml.in _libxl_types.mli.in
 GENERATED_FILES += _libxl_types.inc
 
 all: $(INTF) $(LIBS)
 
 xl.ml: xl.ml.in _libxl_types.ml.in
-       $(Q)sed -e '1i(*\
+       $(Q)sed -e '1i\
+(*\
  * AUTO-GENERATED FILE DO NOT EDIT\
  * Generated from xl.ml.in and _libxl_types.ml.in\
  *)\
 ' \
            -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.ml.in' \
-         < xl.ml.in > xl.ml
+         < xl.ml.in > xl.ml.tmp
+       $(Q)mv xl.ml.tmp xl.ml
 
 xl.mli: xl.mli.in _libxl_types.mli.in
-       $(Q)sed -e '1i(*\
+       $(Q)sed -e '1i\
+(*\
  * AUTO-GENERATED FILE DO NOT EDIT\
  * Generated from xl.mli.in and _libxl_types.mli.in\
  *)\
 ' \
            -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.mli.in' \
-         < xl.mli.in > xl.mli
+         < xl.mli.in > xl.mli.tmp
+       $(Q)mv xl.mli.tmp xl.mli
 
 _libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \
                 $(XEN_ROOT)/tools/libxl/libxltypes.py